<template>
  <div>
      <h1>鉴定方式信息列表</h1>
    <el-alert
      v-if="del_success===1"
      title="删除成功"
      type="success">
    </el-alert>
    <el-table
      :data="info1"
      height="360"
      border>
      <el-table-column
        prop="qid"
        label="鉴定方式编号"
        align="center"
        width="200"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="jid"
        label="鉴定机构编号"
        align="center"
        width="200"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="identifytext"
        label="鉴定方式描述"
        align="center"
        width="450"
        :resizable="false">
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        width="210"
        :resizable="false">
        <template slot-scope="scope">
          <el-button type="text"  @click="add(scope.row.qid)">申请鉴定</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
    export default {
      name: "IdentifyProvideList" ,
      data(){
        return {
          id: '',
          radio1: '鉴定方式编号',
          userinfo: '',
          del_success:'',
          info:[],
          info1:[],
          currentPage: 1,
          pageSize: 2,
          totalItems: 0,
          filterTableDataEnd:[],
          flag:false,
          num:0
        }
      },
      beforeRouteEnter: (to,from,next) => {
        console.log('进入路由之前');//加载数据
        next(vm => {
          vm.selectinfo();
        })
      },
      beforeRouteLeave: (to,from,next) => {
        console.log('进入路由之后');
        next()
      },
      methods:{
        selectinfo: function() {
            this.axios({
              method:"post",
              headers: { 'content-type': 'application/json' },
              url: "http://evidence.frogking.cn/identifyUserController/selectAllIdentifyProvide",
              params:{
                token:localStorage.getItem("token_only")
              }
            }).then(res=>{
              console.log(res)
              if(res["data"]["code"]==='306'){
                this.info1=res["data"]["item"];
                this.userinfo='';
                console.log(res)
              }
              else if(res["data"]["code"]==='307'){
                this.$alert('没有鉴定方式信息', '提示', {
                  confirmButtonText: '确定'
                });
              }
              else if(res["data"]["code"]==='000'){
                this.$alert('token失效', '错误提示', {
                  confirmButtonText: '确定',
                  callback: action => {
                    this.$router.push("/login");
                    localStorage.removeItem("token_only");
                  }
                });
              }
              else if(res["data"]["code"]==='001'){
                this.$alert('身份不满足，禁止操作', '错误提示', {
                  confirmButtonText: '确定'
                });
              }
              else if(res["data"]["code"]==='002'){
                this.$alert('权限不满足，禁止操作', '错误提示', {
                  confirmButtonText: '确定'
                });
              }
            }).catch(function (error) {
              console.log(error);
            });
          },
        add(data){
          this.$router.push('/CaddIdentifyProvide'+'/'+data);
          //console.log(data)
        },
        del:function (op_id){
          this.axios({
            method:"post",
            headers: { 'content-type': 'application/json' },
            url: "http://evidence.frogking.cn/identifyAdmController/deleteIdentifyProvide",
            params:{
              token:localStorage.getItem("token_only"),
              qid:op_id,
            }
          }).then(res=>{
            if(res["data"]["code"]==='302'){
              this.selectinfo();
              this.del_success=1;
            }
            else if(res["data"]["code"]==='303'){
              this.$alert('系统错误！删除异常！', '错误提示', {
                confirmButtonText: '确定',
                callback: action => {
                  this.userinfo="";
                }
              });
            }
            else if(res["data"]["code"]==='000'){
              this.$alert('token失效', '错误提示', {
                confirmButtonText: '确定',
                callback: action => {
                  this.$router.push("/login");
                  localStorage.removeItem("token_only");
                }
              });
            }
            else if(res["data"]["code"]==='001'){
              this.$alert('权限不满足，禁止操作', '错误提示', {
                confirmButtonText: '确定'
              });
            }
            else if(res["data"]["code"]==='002'){
              this.$alert('权限不满足，禁止操作', '错误提示', {
                confirmButtonText: '确定'
              });
            }
          }).catch(function (error) {
            console.log(error);
          });
        }
      }
    }
</script>

<style scoped>
</style>
